package com.ybc.chinese.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;

import com.ybc.chinese.R;
import com.ybc.chinese.adapter.SpecialAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * <p>高中语文专题<p/>
 * Created by Yubch on 17/2/15.
 */
public class ChineseSpecialActivity extends BaseActivity {
    @Bind(R.id.tv_title)
    TextView tvTitle;
    @Bind(R.id.iv_left)
    ImageView ivLeft;
    @Bind(R.id.gv_chinese_special)
    GridView gvChineseSpecial;

    private Context mCtx;
    private SpecialAdapter mAdapter;
    private List<String> datas = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_chinese_special);
        mCtx = this;
        ButterKnife.bind(this);
        initView();
        initData();
    }

    private void initView() {
        tvTitle.setText("高中语文专题");
        ivLeft.setImageResource(R.mipmap.ic_back);
        ivLeft.setVisibility(View.VISIBLE);
        mAdapter = new SpecialAdapter(mCtx);
        gvChineseSpecial.setAdapter(mAdapter);
        gvChineseSpecial.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                switch (position) {
                    case 0: //拼音专题
                        Intent intent = new Intent(mCtx, SpellActivity.class);
                        mCtx.startActivity(intent);
                        break;
                    case 1: //古诗专题
                        intent = new Intent(mCtx, PoetryActivity.class);
                        mCtx.startActivity(intent);
                        break;
                    case 2: //作文专题
                        intent = new Intent(mCtx, CompositionActivity.class);
                        mCtx.startActivity(intent);
                        break;
                    case 3: //成语专题
                        intent = new Intent(mCtx, IdiomActivity.class);
                        mCtx.startActivity(intent);
                        break;
                    case 4: //阅读专题
                        intent = new Intent(mCtx, OutsideReadActivity.class);
                        mCtx.startActivity(intent);
                        break;
                    case 5: //知识归纳
                        intent = new Intent(mCtx, InduceActivity.class);
                        mCtx.startActivity(intent);
                        break;
                    default:
                        String title = datas.get(position);
                        DetailActivity.newIntent(mCtx, title);
                        break;
                }
            }
        });
    }

    @OnClick(R.id.iv_left)
    public void left() {
        finish();
    }

    private void initData() {
        datas.add("拼音专题");
        datas.add("古诗专题");
        datas.add("作文专题");
        datas.add("成语专题");
        datas.add("阅读专题");
        datas.add("知识归纳");
        datas.add("病句类型归纳");
        datas.add("容易读错和写错的汉字");
        datas.add("高考语文词语辨析");
        mAdapter.setDatas(datas);
    }

}
